<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SUB Instruction</title>
<link href="../edit68k.css" rel="stylesheet" type="text/css">
</head>

<body>
<h1 class="heading">SUB Instruction<BR>
</h1>
<hr noshade></h1>
<BR>
<span class="text">Subtracts two binary operands and stores the result in the destination operand.<BR>
<BR>
Two different methods are allowed:<BR>
<BR>
1. Subtract an effective address from a data register.<BR>
2. Subtract a data register from an effective address.</span>
<br>
<br>    
<P class="text">ADDRESS METHODS: 1) Dn, An, (An), (An)+, -(An), x(An), x(An,xr.s), x.w, x.l, x(PC), x(PC,xr.s), #x</P>
<P class="text">ADDRESS METHODS: 2) (An), (An)+, -(An), x(An), x(An,xr.s), x.w, x.l<BR>
          <BR>
  DATA LENGTH: Byte, word, longword<BR>
  <BR>
  When using an address register as destination, byte is not allowed.</P>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="74%">
  <TBODY>
    <TR>
      <TD width="19%" rowSpan=5 vAlign=top class="text">FLAGS:</TD>
      <TD width="81%" class="text">X - Set if a loan was required from the most significant bit, otherwise 0.</TD>
    </TR>
    <TR>
      <TD width="81%" class="text">N - S</TD>
    </TR>
    <TR>
      <TD width="81%" class="text">Z - S</TD>
    </TR>
    <TR>
      <TD width="81%" class="text">C - Same as X</TD>
    </TR>
    <TR>
      <TD width="81%"><span class="text">V - S </span>
          <P>&nbsp;</P></TD>
    </TR>
  </TBODY>
</TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="75%">
  <TBODY>
    <TR>
      <TD width="16%" rowSpan=2 class="text">SYNTAX:</TD>
      <TD width="84%" class="text">SUB Dn,&lt;ea&gt;</TD>
    </TR>
    <TR>
      <TD width="84%" class="text">SUB &lt;ea&gt;,Dn</TD>
    </TR>
  </TBODY>
</TABLE>
<P><span class="text"><BR>
  When an address register is the destination, you use SUBA. Many assemblers will automatically choose SUBA if you write SUB with an address register as destination.</span></P>
<P><span class="text">EXAMPLE CODE:</span></P>
<P class="sourcecode"><span class="text">&nbsp;&nbsp; SUB.B&nbsp;&nbsp;&nbsp; D0,D1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
 
subtracts the lower 8 bits of D0 from D1, does not change the upper 24 bits of D0 or 
D1<br>
&nbsp;&nbsp; SUBW&nbsp;&nbsp;&nbsp; D0,D1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
 
subtracts the lower 16 bits of D0 from D1, does not change the upper 16 bits of D0 or 
D1<br>
&nbsp;&nbsp; SUB.L&nbsp;&nbsp;&nbsp;&nbsp; D0,D1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; subtracts all 32 bits of D0 from D1</span></P>
<P>&nbsp;</P>
<span class="text">
</span><span class="text">
</span><span class="text"><BR>
</span><span class="text"><BR>
</span><span class="text"><BR>
</span><span class="text"><BR>
</span><span class="text">
</span>
</body>
</html>